<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <%@ include file="/common/taglibs.jsp"%>
  <title>中国校校通</title>
  <link href="${ctx}/pages/new/themes/main.css" rel="stylesheet" type="text/css" />
  <LINK href="${ctx}/styles/style.css" type='text/css' rel='stylesheet'>
</head>
<body>
<%@include file="/pages/new/index_top.jsp" %>
<%@include file="/pages/new/index_search.jsp" %>
<table width="1002" align="center" style="margin-bottom:5px;">
  <tr>
    <td style="padding-left: 25px; font-weight: bold; font-size: 14px; color:red;">
      	<img src="${ctx}/images/lt_new/arrow_4.gif">&nbsp;
        <c:if test="${pressName ne null}">${pressName}</c:if>
    	<c:if test="${subjectName ne null}">${subjectName}</c:if>
    	<c:if test="${gradeName ne null}">${gradeName}</c:if>
    	<c:if test="${bookType eq 1}">最新图书</c:if>
		<c:if test="${bookType eq 2}">热销图书</c:if>
		<c:if test="${bookType eq 3}">特价图书</c:if>
    </td>
  </tr>
</table>
<table width="1002" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
		<div style="width: 1000px;">
		<s:iterator value="booklist" var="book">
		  <div class="books">
			<div class="bkphoto">
			  <a href="${ctx}/book/view.do?model.id=${book.id}" target="_blank" title="${book.name}">
				<img width="100" height="130" src="${ctx}${book.coverPhoto}" onError="this.src='${ctx}/images/longtian/book_nophoto_big.gif'">
			  </a>
			</div>
			<div class="bookinfo">
				<a href="${ctx}/book/view.do?model.id=${book.id}" target="_blank" title="${book.name}">${book.name}</a>
			</div>
			<div class="bookinfo">作者：${book.author}</div>
			<div>
			  <img src="${ctx}/images/longtian/but_buy.jpg" border="0"/>
			  <img src="${ctx}/images/longtian/but_coll.jpg" border="0"/>
			</div>
		  </div>
	    </s:iterator>
		</div>
	</td>
  </tr>
	<tr>
		<td align="center">
		<div style="">
		<table align="right">
			<tr>
				<td><c:choose>
					<c:when test="${pgCount eq 0}">
						未查到符合条件的数据！
					</c:when>
					<c:when test="${pgSize gt pgCount}">
						<c:if test="${currentPage > 0}">
							<a href="#" onclick="pageReset(0)">首页</a>&nbsp;&nbsp;
							<a href="#" onclick="pageReset(${currentPage-1})">上一页</a>&nbsp;&nbsp;
						</c:if>
						<c:if test="${currentPage <= 0}">
							<font color="gray">首页</font>&nbsp;&nbsp;
							<font color="gray">上一页</font>&nbsp;&nbsp;
						</c:if>
						<c:if test="${currentPage < pgCount-1}">
							<a href="#" onclick="pageReset(${currentPage+1})">下一页</a>&nbsp;&nbsp;
							<a href="#" onclick="pageReset(${pgCount-1})">尾页</a>&nbsp;&nbsp;
						</c:if>
						<c:if test="${currentPage >= pgCount-1}">
							<font color="gray">下一页</font>&nbsp;&nbsp;
							<font color="gray">尾页</font>&nbsp;&nbsp;
						</c:if>
					</c:when>
				</c:choose></td>
				<td>第<span style="color:red;">${currentPage+1}</span>页/共<span style="color:red;">${pgCount}</span>页&nbsp;&nbsp;</td>
				<td><input id="jumppage" style="width: 30px;" /> <a href="#"
					onclick="jumppage()">GO</a></td>
				<td width="30"></td>
			</tr>
		</table>
		</div>
		</td>
	</tr>
</table>
<%@include file="/pages/new/index_bottom.jsp" %>
<script type="text/javascript">
 function pageReset(currentPage) {
	var bkType = document.getElementById("bookType").value;
	var prsId = document.getElementById("pressId").value;
	var sbjId = document.getElementById("subjectId").value;
	var grdId = document.getElementById("gradeId").value;
	window.location.href = "${ctx}/mainbook/index.do?bookType="+bkType+"&pressId="+prsId+"&subjectId="+sbjId+"&gradeId="+grdId+"&currentPage="+currentPage;
 }
 function jumppage() {
	 var bkType = document.getElementById("bookType").value;
	 var prsId = document.getElementById("pressId").value;
	 var sbjId = document.getElementById("subjectId").value;
	 var grdId = document.getElementById("gradeId").value;
	 var jumppage = document.getElementById("jumppage").value;
	 var regNum =/^\d$/;
	 if(regNum.test(jumppage)&&jumppage-1>=0){
		 var currentPage = jumppage-1;
		 window.location.href = "${ctx}/mainbook/index.do?bookType="+bkType+"&pressId="+prsId+"&subjectId="+sbjId+"&gradeId="+grdId+"&currentPage="+currentPage;
	 }else{
		//alert("请输入大于0的整数！");
	 }
 }
</script>
<script type="text/javascript">
  //添加收藏
  function addFavorite(bkId){
	  $.ajax({
  		url: '${ctx}/favorite/addFavorite.do',
  		type: 'post',
  		dataType: 'json',
  		data: {bookId : bkId},
  		success: function(rst, textStatus){
  	  		if(rst.result == "success"){
  	  		  alert("收藏成功");
  	  	  	}
  	  	  	if(rst.result == "added"){
  	  	  	  alert("已经收藏了该图书！");
  	  	  	}
  	  	  	if(rst.result == "error"){
  	  	  	  alert("您还没有登录，请登录！");
  	  	  	}
  		}
  	  });
  }
</script>
</body>
</html>